<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="f" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>修改资源</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<jsp:include page="../common.jsp"/>
	<!--树组件start -->
	<script type="text/javascript" src="libs/js/tree/ztree/ztree.js"></script>
	<link href="libs/js/tree/ztree/ztree.css" rel="stylesheet" type="text/css"/>
	<!--树组件end -->
	<script type="text/javascript">
		var zTreeObj;
		var zNodes =${jsonString };
		var setting = {
			data: {simpleData: {enable: true}},
			view: {selectedMulti: false},
			check: {enable: true,chkStyle: "radio",radioType: "all"},
			callback: {onClick: onClick,onCheck: onCheck}
		};
		$(function(){
			zTreeObj = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
			$("#node_name").click(function() {
				var offset=$(this).offset();
				var outerHeight=$(this).outerHeight();
				$("#menuContent").css({
					left:offset.left + "px", top:offset.top + outerHeight + "px"
				}).slideDown("fast");
				$("body").bind("mousedown", onBodyDown);
			});
		});
		function onClick(e, treeId, treeNode) {
			zTreeObj.checkNode(treeNode, !treeNode.checked, null, true);
			if(!treeNode.checked && !treeNode.chkDisabled){
				$("#node_id").val("");
				$("#node_name").val("");
			}
		}
		function onCheck(e, treeId, treeNode) {
			$("#node_id").val(treeNode.id);
			$("#node_name").val(treeNode.name);
			hideMenu();
		}
		function onBodyDown(event) {
			if (!(event.target.id=="node_name" || event.target.id=="menuContent" || $(event.target).parents("#menuContent").length>0)) {
				hideMenu();
			}
		}
		function hideMenu() {
			$("#menuContent").fadeOut("fast");
			$("body").unbind("mousedown", onBodyDown);
		}
	</script>
  </head>
  <body>
  	<f:form modelAttribute="resource" action="sys/res/doUpdate">
		<div class="box1" panelWidth="100%">
		<fieldset> 
			<legend>修改资源</legend> 
			<f:hidden path="resourceId"/>
			<table class="tableStyle" formMode="transparent" footer="normal">
				<tr>
					<td width="15%">资源名称：</td>
					<td width="35%">
						<f:input path="resourceName"/>
						<span class="star">*</span>
						<f:errors path="resourceName" cssStyle="color:red"/>
					</td>
				</tr>
				<tr>
					<td width="15%">资源描述：</td>
					<td>
						<f:textarea path="resourceDesc"/>
					</td>
				</tr>
				<tr>
					<td width="15%">资源类型：</td>
					<td>
						<f:radiobuttons path="resourceType" items="${resType }"/>
					</td>
				</tr>
				<tr>
					<td width="15%">资源链接：</td>
					<td>
						<f:input path="resourceUrl" title="请以“/”开头。"/>
					</td>
				</tr>
				<tr>
					<td width="15%">链接方式：</td>
					<td>
						<f:input path="target" title="target属性:“_blank、_self、_top、_parent”或其他指定窗口名称。"/>
					</td>
				</tr>
				<tr>
					<td width="15%">权限名称：</td>
					<td>
						<f:input path="authorityName" title="请以“ROLE_”开头，当资源链接不为空时，权限名称不能为空！"/>
						<f:errors path="authorityName" cssStyle="color:red"/>
					</td>
				</tr>
				<tr>
					<td width="15%">资源优先级：</td>
					<td>
						<f:input path="priority" title="资源优先级只能为数字！" inputMode="numberOnly"/>
						<f:errors path="priority" cssStyle="color:red"/>
					</td>
				</tr>
				<tr>
					<td width="15%">启用状态：</td>
					<td>
						<f:radiobuttons path="enabled" items="${resStatus }"/>
					</td>
				</tr>
				<tr>
					<td width="15%">父节点：</td>
					<td>
						<f:input path="pubResource.resourceName" id="node_name" readonly="true"/>
						<f:hidden path="pubResource.resourceId" id="node_id"/>
					</td>
				</tr>
			</table>
		</fieldset> 
		<div class="height_5"></div>
		<div class="padding_top10">
			<table class="tableStyle" formMode="transparent">
				<tr>
					<td colspan="4">
						<input type="submit" id="submit_button" value="提交">
						<input type="button" value="返回" onclick="location.href='<%=basePath%>sys/res/list'"/>
					</td>
				</tr>
			</table>
		</div> 
	</div>
	</f:form>
    <div id="menuContent" class="menuContent" style="display:none;position:absolute;">
	   <ul id="treeDemo" class="ztree" style="border:1px solid #617775;background:white;width:100%;height:300px;overflow:auto;"></ul>
	</div>
  </body>
</html>
